package com.yoda.mall.admin.service;

import com.yoda.mall.api.SkuStockApi;
import com.yoda.mall.model.entity.pms.SkuStock;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author shawn
 * @date 2022年 12月 18日 20:33
 */
@Service
public class SkuStockService {

    @DubboReference
    private SkuStockApi skuStockApi;


    public List<SkuStock> getSkuByProductId(Long productId, String keyword) {
        return skuStockApi.getSkuByProductId(productId,keyword);
    }

    public Integer updateProductSkuStock(Long productId, List<SkuStock> skuStockList) {
        skuStockList = skuStockList.stream().peek(s->s.setProductId(productId)).collect(Collectors.toList());
        return skuStockApi.updateProductSkuStock(skuStockList);
    }
}
